<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path=request.getContextPath();
%>    

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


	<link href="/resources/css/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="/resources/js/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="/resources/js/jquery.form.js"></script>
	<script type="text/javascript" src="/resources/js/jquery.validate.js"></script>


</head>
<body>
	<form action="/" method="post" name = "selForm">
	
		<input type = "hidden" name = "pageNum" value = "${orderPage.pageNum }">
		订单状态：
			<select name= "order_status">
				<option value="">未选择</option>
				<option value="0" ${ordervo.order_status == 0 ?'selected':'' }>未付款</option>
				<option value="1" ${ordervo.order_status == 1 ?'selected':'' }>已付款</option>
				<option value="2" ${ordervo.order_status == 2 ?'selected':'' }>已发货</option>
				<option value="3" ${ordervo.order_status == 3 ?'selected':'' }>已签收</option>
				<option value="-1" ${ordervo.order_status == -1 ?'selected':'' } >退货申请</option>
				<option value="-2" ${ordervo.order_status == -2 ?'selected':'' }>退货中</option>
				<option value="-3" ${ordervo.order_status == -3 ?'selected':'' }>已退货</option>
				<option value="-4" ${ordervo.order_status == -4 ?'selected':'' }>取消交易</option>
			</select>
		用户售后状态：
			<select name = "after_status">
				<option value="">未选择</option>
				<option value="0" ${ordervo.after_status == 0 ?'selected':'' }>未发起售后</option>
				<option value="1" ${ordervo.after_status == 1 ?'selected':'' }>申请售后</option>
				<option value="-1" ${ordervo.after_status == -1 ?'selected':'' }>售后已取消</option>
				<option value="2" ${ordervo.after_status == 2 ?'selected':'' }>处理中</option>
				<option value="200" ${ordervo.after_status == 200 ?'selected':'' }>处理完毕</option>
			</select>
			
		用户支付渠道：
			<select name = "pay_channel">
				<option value="">未选择</option>
				<option value="0" ${ordervo.pay_channel == 0 ?'selected':'' }>余额</option>
				<option value="1" ${ordervo.pay_channel == 1 ?'selected':'' }>微信</option>
				<option value="2" ${ordervo.pay_channel == 2 ?'selected':'' }>支付宝</option>			
			</select>
		订单结算状态
			<select name = "order_settlement_status">
				<option value="">未选择</option>
				<option value="0" ${ordervo.order_settlement_status == 0 ?'selected':'' }>未结算</option>
				<option value="1" ${ordervo.order_settlement_status == 1 ?'selected':'' }>已结算</option>
			</select>
	
			<input type = "submit" value = "查询">
	</form>
			<input type = "button" value = "批量删除"  onclick = "delList()">
	
<form action="delList" method="post" name = "delForm">
	<table class = "table">
		<tr>
			<td>
				<input type = "checkbox" class = "delSel">
			</td>
			<td>订单编号</td>
			<td>交易号</td>
			<td>客户编号</td>
			<td>商户编码</td>
			<td>商户名称</td>
			<td>订单状态</td>
			<td>用户售后状态</td>
			<td>商品数量</td>
			<td>商品总价</td>
			<td>实际付款金额</td>
			<td>运费金额</td>
			<td>收货地址编码</td>
			<td>支付渠道</td>
			<td>订单支付单号</td>
			<td>第三方支付流水号</td>
			<td>付款时间</td>
			<td>发货时间</td>
			<td>订单结算状态</td>
			<td>订单结算时间</td>
			<td>是否是套餐</td>
			<td>是否积分产品</td>
			<td>电话号码</td>
			<td>修改时间</td>
			<td>删除时间</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${orderPage.list }" var = "order">
			<tr>
				<td>
					<input type = "checkbox" class = "delList" name = "ids" value = "${order.id }">
				</td>
				<td>${order.order_no }</td>
				<td>${order.order_sn }</td>
				<td>${order.member_id }</td>
				<td>${order.supplier_id }</td>
				<td>${order.supplier_name}</td>
				<td>
					<c:choose>
						<c:when test="${order.order_status == 0 }">未付款</c:when>
						<c:when test="${order.order_status == 1 }">已付款</c:when>
						<c:when test="${order.order_status == 2 }">已发货</c:when>
						<c:when test="${order.order_status == 3 }">已签收</c:when>
						<c:when test="${order.order_status == -1 }">退货申请</c:when>
						<c:when test="${order.order_status == -2 }">退货中</c:when>
						<c:when test="${order.order_status == -3 }">已退货</c:when>
						<c:when test="${order.order_status == -4 }">取消交易</c:when>
					</c:choose>
				
				
				</td>
				<td>
				
					<c:choose>
						<c:when test="${order.after_status == 0 }">未发起售后</c:when>
						<c:when test="${order.after_status == 1 }">申请售后</c:when>
						<c:when test="${order.after_status == -1 }">售后已取消</c:when>
						<c:when test="${order.after_status == 2 }">处理中</c:when>
						<c:when test="${order.after_status == 200 }">处理完毕</c:when>
					</c:choose>
				
				
				</td>
				<td>${order.product_count }</td>
				<td>${order.product_amount_total }</td>
				<td>${order.order_amount_total }</td>
				<td>${order.logistics_fee }</td>
				<td>${order.address_id }</td>
				<td>
					<c:choose>
						<c:when test="${order.pay_channel == 0 }">余额</c:when>
						<c:when test="${order.pay_channel == 1 }">微信</c:when>
						<c:when test="${order.pay_channel == 2 }">支付宝</c:when>
					</c:choose>
				</td>
				<td>${order.out_trade_no }</td>
				<td>${order.escrow_trade_no }</td>
				<td>${order.pay_time }</td>
				<td>${order.delivery_time }</td>
				<td>
					<c:choose>
						<c:when test="${order.order_settlement_status == 0 }">未结算</c:when>
						<c:when test="${order.order_settlement_status == 1 }">已结算</c:when>	
					</c:choose>
				
				</td>
				<td>${order.order_settlement_time }</td>
				<td>${order.is_package }</td>
				<td>${order.is_integral }</td>
				<td>${order.telphone }</td>
				<td>${order.updated_at }</td>
				<td>${order.deleted_at }</td>
				<td>
					<a href = "showDetail?id=${order.id }"><input type = "button" value = "查看详情"></a>
				</td>
			</tr>
		
		</c:forEach>	
	</table>
</form>
		<nav aria-label="Page navigation example">
			  <ul class="pagination">
			    <li class="page-item"><a class="page-link" href="javascript:gotoPage(1)">首页</a></li>
			    <c:forEach begin="${orderPage.pageNum-2>1?orderPage.pageNum-2:1}" 
				       end="${orderPage.pageNum+2<orderPage.pages ? orderPage.pageNum+2:orderPage.pages}" step="1" var="page">
				    	<c:if test="${page==orderPage.pageNum}">
				    		<li class="page-item active" aria-current="page">
						      <a class="page-link">
						         ${page}
						        <span class="sr-only">(current)</span>
						      </a>
						    </li>
				    	</c:if>
				    	<c:if test="${page!=orderPage.pageNum}">
		    		<li class="page-item"><a class="page-link" href="javascript:gotoPage(${page })" >${page}</a></li>
		    		</c:if>    	
		    		</c:forEach>
			    <li class="page-item"><a class="page-link" href="javascript:gotoPage(${orderPage.pages })">尾页</a></li>
			  </ul>
			</nav>
			
	
	<script type="text/javascript">
	
		function gotoPage(pageNum){
			
			alert(pageNum);
			$("input[name='pageNum']").val(pageNum);
			$("form[name='selForm']").submit();
			
		}
	
		function delList(){
			
			alert("11");
			$("form[name='delForm']").ajaxSubmit(function(msg){
				
				if(msg > 0){
					alert("删除成功!");
					$("form[name='selForm']").submit();
				}
				if(msg == 5){
					alert("未选择要删除的订单");
				}
				
			})
			
		}
	
	
	
	
	
	</script>
	

</body>
</html>